FROM php:7.1.11-fpm-alpine3.4
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories





RUN apk add --update nginx supervisor bash 

RUN  apk add zlib-dev \
    && docker-php-ext-install  zip 

RUN docker-php-ext-install pdo pdo_mysql 
 


RUN  rm -rf /var/cache/apk/* \
    && chown -R nginx:www-data /var/lib/nginx

RUN mkdir -p /etc/nginx/sites-available && \
	mkdir -p /etc/nginx/sites-enabled && \
	mkdir -p /run/nginx

ADD supervisord.conf /etc/supervisord.conf
ADD nginx.conf /etc/nginx/nginx.conf
# ADD sites/*.conf /etc/nginx/sites-enabled/
ADD sites/default.conf /etc/nginx/sites-enabled/

ADD src/ /var/www/html/

RUN chown nginx:www-data /etc/nginx -R && \
    chown nginx:www-data /run/nginx && \
    chown nginx:www-data /var/www/html -R 


RUN sed -i \
        -e "s/user = www-data/user = nginx/g" \
        -e "s/;listen.mode = 0660/listen.mode = 0666/g" \
        -e "s/;listen.owner = www-data/listen.owner = nginx/g" \
        -e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" \
        -e "s/^;clear_env = no$/clear_env = no/" \
        /usr/local/etc/php-fpm.d/www.conf


# 添加计划任务
# RUN echo "*       *       *       *       *       echo 'f' >> /tmp/2" >> /etc/crontabs/root
RUN echo "30       0       *       *       *       crul localhost/index.php/mahjongrefresh " >> /etc/crontabs/root
RUN  sed -i '/\#\!\/bin\/sh/a\crond' /usr/local/bin/docker-php-entrypoint
# RUN  sed -i '/\#\!\/bin\/sh/a\curl localhost/index.php/onetoken' /usr/local/bin/docker-php-entrypoint
RUN  echo 'curl localhost/index.php/onetoken' >> /usr/local/bin/docker-php-entrypoint


# CMD /usr/bin/supervisord -n -c /etc/supervisord.conf

ADD env.sh /root/env.sh
RUN chmod +x /root/env.sh
CMD [ "/root/env.sh" ]


